﻿using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Xms.Abp.Domain;
using Xms.Abp.Settings;

namespace SettingsManagement;

public class SettingsManagementProvider : XmsDomainService, ISettingsManagementProvider, ITransientDependency
{
    protected ISettingsManager SettingsManager => LazyInject<ISettingsManager>();

    public virtual async Task SetAsync(string typeName, string providerName, string providerKey, SettingsValues values, CancellationToken cancellationToken = default)
    {
        await SettingsManager.SetAsync(typeName, values, providerName, providerKey, cancellationToken);
    }

    public virtual async Task ResetAsync(string typeName, string providerName, string providerKey, CancellationToken cancellationToken = default)
    {
        await SettingsManager.ResetAsync(typeName, providerName, providerKey, cancellationToken);
    }

    public async Task<SettingsInfo> GetSettingsInfoAsync(string typeName, string providerName, string providerKey, CancellationToken cancellationToken = default)
    {
        return await SettingsManager.GetSettingsInfoAsync(typeName, providerName, providerKey, cancellationToken);
    }

    public List<SettingsTypeInfo> GetEditableSettingsTypes(string providerName)
    {
        return SettingsManager.GetEditableSettingsTypes(providerName);
    }

    public List<SettingsTypeInfo> GetEditableEnumSettingsTypes(string providerName)
    {
        return SettingsManager.GetEditableEnumSettingsTypes(providerName);
    }
}
